
<div id="data_page" class="in_page">
  <div class="panel panel-default">

<!--添加菜单-->
<div class="btn-group" role="group" aria-label="...">
          <a href="{:U('Award/add_award_index')}"><button type="button" class="btn btn-primary">添加优惠券</button></a>          
</div>
</div>
</div>

      <table class="table table-bordered" style="text-align:center">
        <thead>
          <tr>
            <th><span class="glyphicon glyphicon-leaf"></span>券名</th>
            <th><span class="glyphicon glyphicon-leaf"></span>总数量</th>
            <th><span class="glyphicon glyphicon-leaf"></span>剩余数量</th>
            <th><span class="glyphicon glyphicon-leaf"></span>类型</th>
            <th><span class="glyphicon glyphicon-leaf"></span>概率</th>
            <th><span class="glyphicon glyphicon-leaf"></span>使用范围</th>
            <th><span class="glyphicon glyphicon-leaf"></span>使用条件</th>
            <th><span class="glyphicon glyphicon-leaf"></span>创建时间</th>
            <th><span class="glyphicon glyphicon-leaf"></span>最后操作时间</th>
            <th><span class="glyphicon glyphicon-leaf"></span>开始时间</th>
            <th><span class="glyphicon glyphicon-leaf"></span>截止时间</th>
            <th><span class="glyphicon glyphicon-leaf"></span>操作</th>
            <th><span class="glyphicon glyphicon-leaf"></span>生成优惠券链接</th>
          </tr>     
        </thead>
        <tbody>
         <volist name="list" id="data">
          <tr>
            <td>{$data['name']}</td>
            <td>{$data['num']}</td>
            <td>{$data['num']-$data['balance']}</td>
            <td>
              <if condition="$data['type'] eq '1'">打折券</if>
              <if condition="$data['type'] eq '2'">服务券</if>
              <if condition="$data['type'] eq '3'">节日生日券</if>
              <if condition="$data['type'] eq '4'">活动入场券</if>
            </td>
            <td>{$data['percent']}</td>
            <td>{$data['area']}</td>
            <td>{$data['tiaojian']}</td>
            <td>{$data['ctime']}</td>
            <td>{$data['mtime']}</td>
            <td><?php echo date('Y-m-d H:i:s',$data['starttime']);?></td>
            <td><?php echo date('Y-m-d H:i:s',$data['endtime']);?></td>     
            <td>
               <div class="btn-group" role="group" aria-label="...">
                  <a href="{:U('Award/update_award_index',array('id'=>$data['id']))}"><button type="button" class="btn btn-primary btn-xs">修改</button></a>
                  <a href="{:U('Award/del_award',array('id'=>$data['id']))}"  onclick="return confirm('是否确认删除？')"><button type="button" class="btn btn-danger btn-xs">删除</button></a>
               </div>
           </td>
           <td>
           	 <button type="button" class="btn btn-primary btn-xs ling" did="{$data['id']}" >生成领券链接</button>
           </td>
          </tr>
        </volist>
        </tbody>
      </table> 
</div>

<div class="modal" id="addnewModal">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
     
      </div>
      <div class="modal-body">
      <form class="form-horizontal">
		  <div class="form-group">
		    <label for="inputKey" class="col-sm-2 control-label">领券链接</label>
		    <div class="col-sm-10">
		      <input type="text" class="form-control" id="inputKey" name="inputKey" readonly >
		    </div>
		  </div>
		  </form>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
      
      </div>
    </div>
  </div>
</div>

<script type="text/javascript">
	

	$(".ling").click(function(){
		var id=$(this).attr("did");
		
		$.get("http://sunwayuchoice.com/admin.php/Award/url",{id:id},function(obj){
			if(obj.s=="ok"){
				$("#addnewModal").show();
				$("#inputKey").val(obj.m);
			//	alert(obj.m);
			}else{
				alert("生成失败");
			}
			
		});
		
	});
</script>
<script type="text/javascript">
	$(function(){
		$("#addnewModal").hide();
	});
	$(".btn").click(function(){
		$("#addnewModal").hide();
	});
//	$("#saveBtn").click(function(){
//		var Url2=document.getElementById("inputKey");
//		Url2.select("inputKey"); // 选择对象
//		document.execCommand("Copy"); // 执行浏览器复制命令  
//		alert("已复制好，可贴粘。");
//	});
</script>